<?php
	//echo $this->userType;
	$para=$_GET;

	// 用户名限制
		if($para['username'] && $para['username']!='用户名'){
			$para['username']=wjStrFilter($para['username']);
			if(!ctype_alnum($para['username'])) throw new Exception('用户名包含非法字符,请重新输入');
			$whereStr .= " and u.username like '%{$para['username']}%' and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} ) ";
		}

		switch($para['utype']){
			case 1:
				//我自己
				$whereStr .= " and b.uid={$this->user['uid']} ";
				break;
			case 2:
				//直属下线
				if($this->user['type']==1){
				$whereStr.=" and u.parentId={$this->user['uid']} and u.type=0 ";
				}elseif($this->user['type']==2){
				$whereStr.=" and u.zparentId={$this->user['uid']} and u.type=1 or (u.zparentId={$this->user['uid']} and u.parentId='' and u.type=0) ";
				}elseif($this->user['type']==3){
				$whereStr.=" and u.gudongId={$this->user['uid']} and u.type=2 or (u.gudongId={$this->user['uid']} and u.zparentId='' and u.parentId='' and u.type!=3) ";
				}
				break;
			case 3:
				// 所有下级
				$whereStr .= "  and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} or u.uid={$this->user['uid']} ) and u.uid !={$this->user['uid']} ";
				break;
			default:
				// 所有人
				$whereStr .= "  and (u.parentId={$this->user['uid']} or u.zparentId={$this->user['uid']} or u.gudongId={$this->user['uid']} or u.uid={$this->user['uid']} ) ";
			break;
		}



// 用户限制
if($para['username'] && $para['username']!="用户名"){
	$para['username']=wjStrFilter($para['username']);
	if(!ctype_alnum($para['username'])) throw new Exception('用户名包含非法字符,请重新输入');
	$userWhere="and u.username like '%{$para['username']}%'";
}

// 时间限制
if($para['fromTime'] && $para['toTime']){
	$fromTime=strtotime($para['fromTime']);
	$toTime=strtotime($para['toTime'])+24*3600;
	$timeWhere="and c.actionTime between $fromTime and $toTime";
}elseif($para['fromTime']){
	$fromTime=strtotime($para['fromTime']);
	$timeWhere="and c.actionTime>=$fromTime";
}elseif($para['toTime']){
	$toTime=strtotime($para['toTime'])+24*3600;
	$timeWhere="and c.actionTime<$fromTime";
}else{
	$timeWhere=' and c.actionTime>'.strtotime('00:00');
}

$sql="select b.name bankName, c.*, u.username userAccount, u.gudongId, u.zparentId, u.parentId, d.countname from {$this->prename}bank_list b, {$this->prename}member_cash c, {$this->prename}members u,{$this->prename}member_bank d where c.state<5 and b.isDelete=0 and c.isDelete=0 $timeWhere $userWhere and c.bankId=b.id $whereStr and u.uid=d.uid order by c.id desc";
//$sql;
$data=$this->getPage($sql, $this->page, $this->pageSize);
$stateName=array('已到帐','申请中','已取消','已支付','已失败','已删除');

	$params=http_build_query($para, '', '&');
?>
<div>
<table width="100%" class='table_b'>
	<thead>
		<tr class="table_b_th">
			<th>UserID</th>
			<th>用户名</th>
			<th>提现金额</th>
			<th>银行类型</th>
			<th>开户姓名</th>
			<th>银行账号</th>
			<th>开户行</th>
			<th>时间</th>
			<th>状态</th>
		</tr>
	</thead>
	<tbody class="table_b_tr">
	<?php if($data['data']){
	foreach($data['data'] as $var){ ?>
		<tr>
			<td><?=$var['uid']?></td>
			<td><?=htmlspecialchars($var['userAccount'])?></td>
			<td><?=$var['amount']?></td>
			<td><?=htmlspecialchars($var['bankName'])?></td>
			<td><?=htmlspecialchars($var['username'])?></td>
			<td><?=htmlspecialchars($var['account'])?></td>
			<td><?=htmlspecialchars($var['countname'])?></td>
			<td><?=date('Y-m-d H:i', $var['actionTime'])?></td>
			<td>
				<?php
				if($var['state']==3){
					echo '<div class="sure" id="', $var['id'], '"></div>';
				}else if($var['state']==4){
					echo '<span title="'.$var['info'].'" style="cursor:pointer; color:#f00;">'.$stateName[$var['state']].'</span>';
				}else{
					echo $stateName[$var['state']];
				}
				?>
			</td>
		</tr>
	<?php } }else{ ?>
    <tr><td colspan="12">暂无提现信息</td></tr>
    <?php } ?>
	</tbody>
</table>
<?php
	$this->display('inc_page.php',0,$data['total'],$this->pageSize, "/index.php/{$this->controller}/{$this->action}-{page}/?$params");
?>
</div>